package day0411;

import java.util.Random;
import java.util.Scanner;

public class Test11 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入班级总组数:");
        int groupCount = scanner.nextInt();
        System.out.print("请输入班级中每组的人数:");
        int studentCountPerGroup = scanner.nextInt();
        int[][] grades = new int[groupCount][studentCountPerGroup];
        Random random = new Random();
        int totalFailCount = 0;
        int totalScore = 0;
        double minGroupAverage = 0;
        for (int i = 0; i < groupCount; i++) {
            int groupFailCount = 0;
            int groupTotalScore = 0;
            for (int j = 0; j < studentCountPerGroup; j++) {
                grades[i][j] = random.nextInt(101);
                if (grades[i][j] < 60) {
                    groupFailCount++;
                    totalFailCount++;
                }
                groupTotalScore += grades[i][j];
                totalScore += grades[i][j];
            }
            double groupAverage = (double) groupTotalScore / studentCountPerGroup;
            if (groupAverage > minGroupAverage) {
                minGroupAverage = groupAverage;
            }
            System.out.printf("第%d组不及格人数为: %d 人\n", i + 1, groupFailCount);
            System.out.printf("第%d组平均分为: %.0f\n", i + 1, groupAverage);
        }
        double classAverage = (double) totalScore / (groupCount * studentCountPerGroup);
        System.out.printf("班级中单组最高平均分为:%.0f\n", minGroupAverage);
        System.out.printf("班级中不及格人数为: %d 人\n", totalFailCount);
        System.out.printf("班级总平均分为: %.0f\n", classAverage);
    }
}    